<?php


namespace App\Http\Controllers\Pc\Invoice;


use App\Http\Controllers\Pc\Controller;
use App\Services\Pc\Invoice\InvoiceService;
use Illuminate\Http\Request;

class InvoiceController  extends Controller
{
    public $menu = 3;
    public $invoiceService;

    public function __construct(InvoiceService $invoiceService)
    {
        $this->invoiceService = $invoiceService;

    }

    //百望云

    /**
     * 开票
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function salesInvoiceOpen(Request $request)
    {
        $bill_num = $request->get('bill_num','');
        $user = $this->getUser();
        $data = $this->invoiceService->salesInvoiceOpen($bill_num,$user);
        return $this->data($data);
    }


    /**
     * 打印
     *
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\DingoException
     */
    public function salesInvoicePrint(Request $request)
    {
        $bill_num = $request->get('bill_num','');
        $user = $this->getUser();
        $data = $this->invoiceService->salesInvoicePrint($bill_num,$user);
        return $this->data($data);
    }


    /**
     * 发票作废
     *
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\DingoException
     */
    public function salesInvoiceInvalid(Request $request)
    {

        $bill_num = $request->get('bill_num','');
        $user = $this->getUser();
        $data = $this->invoiceService->salesInvoiceInvalid($bill_num,$user);
        return $this->data($data);
    }


    /**
     * 发票浏览
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\DingoException
     */
    public function salesInvoicePrintPreview(Request $request)
    {
        $bill_num = $request->get('bill_num','');
        $user = $this->getUser();
        $data = $this->invoiceService->salesInvoicePrintPreview($bill_num,$user);
        return $this->data($data);
    }

}